package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_common_dictionary")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.CommonDictionaryMapper")
public class CommonDictionaryDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 字典类型
     */
    @TableField(value = "type")
    private String type;

    /**
     * 描述
     */
    @TableField(value = "description")
    private String description;

    /**
     * 系统id
     */
    @TableField(value = "system_id")
    private Long systemId;

    /**
     * key值
     */
    @TableField(value = "key")
    private String key;

    /**
     * 健值
     */
    @TableField(value = "value")
    private String value;

    public CommonDictionaryVo buildVo() {
        return new CommonDictionaryVo(id, type, description, systemId, key, value);
    }

    public static CommonDictionaryDO of(CommonDictionaryVo vo) {
        return new CommonDictionaryDO(vo.getId(), vo.getType(), vo.getDescription(), vo.getSystemId(), vo.getKey(), vo.getValue());
    }
}
